//
//  LTFReadDetailTableCell.m
//  NeteaseNews
//
//  Created by liutaifeng on 16/4/23.
//  Copyright © 2016年 liutaifeng. All rights reserved.
//

#import "LTFReadDetailTableCell.h"
#import "IsNight.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
@interface LTFReadDetailTableCell ()
@property (nonatomic, retain) UIView *myView;
@end


@implementation LTFReadDetailTableCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView {
    
    self.myView = [[UIView alloc] init];
    [self.contentView addSubview:_myView];
    [_myView release];
    
    
    self.titleImageView = [[UIImageView alloc] init];
    [_myView addSubview:_titleImageView];
    [_titleImageView release];
    
    
    self.title = [[UILabel alloc] init];
    [_myView addSubview:_title];
    [_title release];
    
    
    self.date = [[UILabel alloc] init];
    [_myView addSubview:_date];
    [_date release];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    if ([IsNight nowIsNight]) {
        self.contentView.backgroundColor = [UIColor blackColor];
        _myView.backgroundColor = [IsNight nightColor];
        _title.textColor = [IsNight textNightColor];
        _date.textColor = [IsNight textNightColor];
    }
    else {
        self.contentView.backgroundColor = [UIColor whiteColor];
        _myView.backgroundColor = [UIColor whiteColor];
        _title.textColor = [UIColor blackColor];
        _date.textColor = [UIColor blackColor];
    }
    self.myView.frame = CGRectMake(10, 10, WIDTH - 20, HEIGHT - 20);
    self.myView.layer.borderWidth = 1;
    self.myView.layer.cornerRadius = 5;
    
    self.titleImageView.frame = CGRectMake(10, 10, WIDTH / 3 + 30, HEIGHT - 40);

    self.title.frame = CGRectMake(WIDTH / 3 + 60, 10, WIDTH / 2 - 25, 30);
    self.title.numberOfLines = 0;
    [self.title sizeToFit];
    self.date.frame = CGRectMake(WIDTH / 2 + 50, HEIGHT - 60, WIDTH / 3 - 25, 30);
    self.date.textColor = [UIColor grayColor];
    self.date.textAlignment = NSTextAlignmentRight;
    self.date.font = [UIFont systemFontOfSize:13];
}
@end
